// RedRound.cpp: implementation of the CRedRound class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "8085.h"
#include "RedRound.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CRedRound::CRedRound() : CShape()
{
    Init();
}

CRedRound::CRedRound(CPoint center,int radius) : CShape()
{
    Init();
    SetProperty(center,radius);
}

CRedRound::CRedRound(int x,int y,int radius) : CShape()
{
    Init();
    SetProperty(x,y,radius);
}

CRedRound::~CRedRound()
{

}

void CRedRound::SetProperty(CPoint center,int radius,BOOL bFill)
{
    m_Center = center;
    m_nRadius = radius;
    SetVirtualLength(2*radius);
    // this controls wether to shade the inner portion of the circle or not
    m_bFill = bFill; 
}

void CRedRound::SetProperty(int x,int y,int radius,BOOL bFill)
{
    m_Center.x = x;
    m_Center.y = y;
    m_nRadius = radius;
    SetVirtualLength(2*radius);
    // this controls wether to shade the inner portion of the circle or not
    m_bFill = bFill;
}

CPoint & CRedRound::GetProperty(int &radius)
{
    radius = m_nRadius;
    return m_Center;
}

int CRedRound::Draw(CDC * pDC, BOOL bErase)
{
    // if m_bFill is FALSE then erase the circle 
    CBrush fill(bErase || !m_bFill ? pDC->GetBkColor() : m_FillColour);
    CPen pen(PS_SOLID,1,(bErase ? pDC->GetBkColor() : m_BorderColour));

	CBrush *saveBrush = pDC->SelectObject(&fill);
    CPen *savePen = pDC->SelectObject(&pen);
    CPoint p(6,6);

	pDC->Ellipse(m_Center.x,m_Center.y,m_Center.x+m_nRadius,
        m_Center.y+m_nRadius);
	//pDC->ExtFloodFill(m_nProperty.left+1,m_nProperty.top+1,
    //        pDC->GetBkColor(),FLOODFILLSURFACE);
    pDC->SelectObject(saveBrush);    // restore the saved brush
    pDC->SelectObject(savePen);
    return GetVirtualLength();
}

void CRedRound::Init()
{
    m_Center.x = m_Center.y = 0;
    COLORREF c = RGB(98,0,0);
    SetBorderColour(c);
    SetFillColour(c);
    m_bFill=FALSE;
}
